const person = {
  name: "张三",
  // 本身就是属性访问器
  get aliasName() {
    return this.name + "handsome";
  },
};
const proxyPerson = new Proxy(person, {
  // receiver 代理对象
  get(target, key, receiver) {
    console.log("get", key);
    // return target[key]; // 取出的是person.name 此时this指向person，导致没有被代理
    // return receiver[key]; // 会导致死循环 因为一访问代理对象就会触get
    return Reflect.get(target, key, receiver); // 等价于receiver[key]
  },
  set(target, key, value) {
    // target[key] = value;
    return Reflect.set(target, key, value);
  },
});
console.log(person.aliasName);
console.log(proxyPerson.aliasName);
